<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <img src="" alt="" id="pic" width="500">
    <input type="file" id="file" />
    <script>
        // es6 file对象 Blob对象
        document
            .getElementById('file')
            .addEventListener('change', (event) => {
                const file = event.target.files[0];
                // console.log(Object.prototype.toString.call(file))
                const URL = window.URL;
                const objectUrl = URL.createObjectURL(file);
                // console.log(objectUrl)
                const pic = document.getElementById('pic');
                pic.src = objectUrl;
                pic.onload = function() {
                    URL.revokeObjectURL(objectUrl);
                    console.log('为了jingjing')
                }
            })
    </script>
</body>

</html>